<h1>Edita assistenza</h1>

<%= error_messages_for :assistance %>

<% form_for(@assistance) do |f| %>
  <div id="campi">
		<div id="notes"><p><label for="assistance_notes">Note: </label><br />
			<%= f.text_area :notes, :size => "30x14" %></p></div>
		<p><label for="assistance_short_desc">Descrizione breve: </label><br /><%= f.text_field :short_desc %></p>
    <p><label for="assistance_operator_id">Operatore: </label><br />
    <%= collection_select(:assistance, :operator_id, Operator.find(:all), :id, :login, :prompt => "Seleziona Operatore") %></p>
    <p><label for="assistance_client_id">Cliente: </label><br />
    <%= collection_select(:assistance, :client_id, Client.find(:all), :id, :name_or_society, :prompt => "Seleziona Cliente") %></p>
    <p><label for="assistance_urgency">Tassativa</label><%= f.check_box :urgency %></p>
    <p><label for="assistance_ticket_state">Stato ticket: </label><br />
    <select name="assistance[ticket_state]"><!-- TODO: creare select dinamico -->
      <option value="0" <% if @assistance.ticket_state.zero? %><%= 'selected="selected"' %><% end %>>Non completato</option>
      <option value="1" <% if @assistance.ticket_state == 1 %><%= 'selected="selected"' %><% end %>>Completato Parz.</option>
      <option value="2" <% if @assistance.ticket_state == 2 %><%= 'selected="selected"' %><% end %>>Completato</option>
    </select></p>
    <p><label for="assistance_expiration">Scadenza: </label><br />
		<%= calendar_date_select_tag "assistance[expiration]", @assistance.expiration, :time => true %></p>
	  <p><label for="assistance_execution">Completata il: </label><br />
    <%= calendar_date_select_tag "assistance[execution]", @assistance.execution, :time => true %></p>
	  <p><label for="assistance_created_at">Data creazione: </label><br />
	  <%= calendar_date_select_tag "assistance[created_at]", @assistance.created_at, :time => true %></p>
		<p><label for="assistance_token">Valore: </label><br /><%= f.text_field :token, :size => 5 %></p>
    <p><label for="assistance_duration">Durata intervento: </label><br />
    <%= time_select 'assistance', 'duration', :minute_step => 15, :time_separator => ':' %></p>
		
		<%= render :partial => 'operations' %>
		<br /><br />
    <%= f.submit "Update" %>
  </div>
<% end %>

<br />
<%= link_to 'Show', @assistance %> |
<%= link_to 'Back', :back %>

<div id="add_operation" style="display:none">
	<% form_remote_tag :url => {:controller => 'operations', :action => 'create'},
	    :html => {:id => 'operation_form'} do %>
		<p><label for="operation_description">Descrizione: </label><br /><input id="operation_description" name="operation[description]" size="30" type="text" /></p>
		<br />
    <input id="operation_submit" name="commit" type="submit" value="Crea operazione" />
	<% end %>
</div>